﻿using EGNExtractor;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.IO;

namespace EGNExtractor.Test
{
    [TestClass()]
    public class EGNExtractorTest
    {
        [TestMethod()]
        public void ExtractEGNTest()
        {
            EGNExtractor test = new EGNExtractor();
            string input = "088 / 12-34-56. I have 2 sons. Peter is the oldest. His EGN is: 6203120707.";
            EGNExtractor.ExtractEGN(input);
            Assert.AreEqual(1, EGNExtractor.Egns.Count);
            Assert.AreEqual("6203120707", EGNExtractor.Egns[0]);
        }

        [TestMethod()]
        public void ExtractNoEGNTest()
        {
            EGNExtractor test = new EGNExtractor();
            string input = "088 / 12-34-56. I have 2 sons. Peter is the oldest. His EGN is: 62031ad20707.";
            EGNExtractor.ExtractEGN(input);
            Assert.AreEqual(0, EGNExtractor.Egns.Count);
        }

        [TestMethod()]
        [ExpectedException(typeof(FileNotFoundException))]
        public void ReadWrongFileTest()
        {
            string inputFile = "alabala";
            EGNExtractor_Accessor.ReadFile(inputFile);
        }

        [TestMethod()]
        public void ReadFileTest()
        {
            string inputFile = "../../../EGNExtractor/persons.txt";
            EGNExtractor_Accessor.ReadFile(inputFile);
        }

        [TestMethod()]
        [DeploymentItem("EGNExtractor.exe")]
        public void MainTest()
        {
            EGNExtractor_Accessor.Main();
        }
    }
}
